<!--sidebar-menu-->
<div id="sidebar" class="clearfix"><!-- <a href="#" class="visible-phone"><i class="icon icon-home"></i> Dashboard</a> -->
  <ul style="display: block;">
  {% include "common/menu.html" %}
  </ul>
</div>
<!--end sidebar-menu-->

<div id="content">
  
    <div class="container-fluid" style="padding: 0;">
      <div class="widget-box tab-tabs" >
          <div class="widget-title">
            <ul class="nav nav-tabs">
                {% include "common/tab.html" %}
            </ul>
          </div>
          <div class="widget-content tab-content">
            <div id="tab1" class="tab-pane active">
              <div class="container-fluid">
                <div class="row-fluid" style="margin: 20px 0 ;overflow: hidden;">
                    <form id="signingSearch" class="form-search">
                        <input id="isFamily" type="hidden" >
                        <span style="font-size:20px; line-height: 30px">配置给正在直播的房间加机器人的规则</span>
                        <span class="find-search pull-right">
                        <button  type="button" class="btn btn-purple" onclick="mofcontentDialog('添加')">添加</button>
                        </span>
                    </form>
                </div>

                <div class="row-fluid">
                    <div id="collapseG3" class="widget-content nopadding updates collapse in">
                        <!--<div class="new-update clearfix">-->
                            <!--<div class="new-content">ddd</div>-->
                            <!--<div class="new-content">-->
                                <!--<span class="pull-right"><a onclick="delcontentDialog()">删除</a></span>-->
                                <!--<span class="pull-right">|</span>-->
                                <!--<span class="pull-right"><a onclick="mofcontentDialog('修改')">修改</a></span>-->
                            <!--</div>-->
                        <!--</div>-->
                    </div>
                </div>
                  {% include "common/pagination.html" %}
            </div>

            </div>

            
         </div>
        </div>
    
    </div>

</div>

 <div id="contentDialog" style="display: none">
    <div class="row-fluid" style="margin: 20px 0;overflow: hidden;">
        <span style="font-size:20px;">请输入消息内容:</span>
    </div>
    <div class="row-fluid">
        <textarea id="textarea" rows="5" style="width: 98%"></textarea>
    </div>
 </div>

<div id="mofcontentDialog" style="display: none">
    <div class="row-fluid" style="margin: 20px 0;overflow: hidden;">
        <span style="font-size:20px;">请输入消息内容:</span>
    </div>
    <div class="row-fluid">
        <textarea id="moftextarea" rows="5" style="width: 98%"></textarea>
    </div>
</div>

<!--<script type="text/javascript" src="{{static_url('web/js/jquery.range.js')}}"></script>-->
<!--<script type="text/javascript" src="{{static_url('web/js/91ns.room.js')}}"></script>-->
<!--<link rel="stylesheet" href="{{static_url('web/css/jquery.range.css')}}">-->
<script type="text/javascript">

  $(function(){
      content();
  });

  function content(index){

      var data={};
      data.page=index||1;
      data.pageSize=global.pageSize;
      $.ajax({
          type: "POST",
          data:data,
          url: '/ajax/content',
          dataType: 'json',
          success: function (res) {
              var data=res.data;

              var count=document.getElementById('count');
              count.innerHTML=data.count;
              $('#collapseG3').html('');
              for(var i=0;i<data.list.length;i++){
                 $('#collapseG3').append(contentlist(data.list[i]));
              }

              if(!index||index==0){
                  utilsPagination("#pagination",data.count,global.pageSize,function(page_index,jq){
                      page_index+= 1;
                      content(page_index);
                  });
              }
          }
      });
  }

  function contentlist(data){
      var html='';
      html+='<div class="new-update clearfix"><div class="new-content">'+data.content+'</div><div class="new-content"><span class="pull-right"><a onclick="delcontentDialog('+data.id+')">删除</a></span>';
      html+='<span class="pull-right">|</span><span class="pull-right"><a onclick="mofcontentDialog(\'修改\','+data.id+')">修改</a></span></div></div>';
      return html;
  }

  function mofcontentDialog(title,id){

      $('#mofcontentDialog').dialog({
          autoOpen:true,
          width:500,
          height:310,
          title:title,
          resizable:false,
          modal:true,
          open:function(){
              if(id&&id!='') {
                  var data={};
                   data.id=id;
                  $.ajax({
                      type: "POST",
                      data: data,
                      url: '/ajax/getIdMessage',
                      dataType: 'json',
                      success: function (res) {
                          if (res.code == 0) {
                              $('#moftextarea').val(res.data.data.content);
                          }
                          else {
                              alert('操作失败');
                          }
                      }
                  });
              }
          },
          buttons: {
              "确定": function () {
                  var content=$('#moftextarea').val();
                  var data={};
                  if(id&&id!='') {
                      data.id = id;
                  }else{
                      data.id=0;
                  }
                  data.content=content;
                  $.ajax({
                      type:"POST",
                      data:data,
                      url:'/ajax/edit',
                      dataType:'json',
                      success:function(res){
                          if(res.code==0){
                              location.href='/room/content';
                          }
                          else{
                              alert('操作失败');
                          }
                      }
                  })

              }
          }
      });
  }

  function delcontentDialog(id){
          var data={};
          data.id = id;
          $.ajax({
              type:"POST",
              data:data,
              url:'/ajax/del',
              dataType:'json',
              success:function(res){
                  if(res.code==0){
                      location.href='/room/content';
                  }
                  else{
                      alert('操作失败');
                  }
              }
          })
  }
  
</script>